package learning.designpatterns.strategy.payments;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by bibro on 16.03.14.
 */
public class ShoppingCard {

    private List<Item> items;

    public ShoppingCard() {
        this.items = new ArrayList<Item>();
    }

    public void addItem(Item item) {
        items.add(item);
    }

    private int getTotal() {
        int total = 0;
        for (Item item : items)
            total += item.getPrice();

        return total;
    }

    public void pay(PaymentStrategy paymentStrategy) {
        System.out.println("PAYING FOR:\n"+items);
        paymentStrategy.pay(getTotal());
    }
}
